<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>detectLanguage</title>
</head>

<body>
    <script>
        const detectLanguage = (defaultLang = 'en-US') =>
            navigator.language ||
            (Array.isArray(navigator.languages) && navigator.languages[0]) ||
            defaultLang;
        document.writeln(detectLanguage());
    </script>
</body>

</html>